<template>
  <div class="banxin">
    <main class="tanxin">
      <aside>
        <img class="avatar" :src="userInfo.headImg" alt />
        <div class="userInfo">
          <span>{{ userInfo.nickName }}</span>
          <a href>【退出】</a>
        </div>
        <div class="title">
          <img src="../assets/images/person/transaction.png" alt /> 交易管理
        </div>
        <ul>
          <li
            @click="$router.push('/user/Center')"
            :class="{ active: $route.path.includes('Center') }"
          >个人中心</li>
          <li>我的订单</li>
          <li
            @click="$router.push('/user/cart')"
            :class="{ active: $route.path.includes('cart') }"
          >购物车</li>
          <li>消息通知</li>
          <li>积分明细</li>
          <li>积分攻略</li>
        </ul>
        <div class="title">
          <img src="../assets/images/person/information.png" alt />
          个人信息管理
        </div>
        <ul>
          <li>地址管理</li>
          <li>账号安全</li>
        </ul>
      </aside>
      <article>
        <router-view @updateKeyFn="$emit('updateKeyFn')"></router-view>
      </article>
    </main>
  </div>
</template>

<script>
import { UserInfoApi } from "@/request/api";
export default {
  data() {
    return {
      breadArr: ["首页", "个人中心"],
      asideActive: 0,
      userInfo: {
        // 用户头像
        headeImg: require("../assets/images/userImg.png"),
        // 用户名
        nickName: "游客",
        // 积分数
        coin: "--",
        // 购物车商品数量
        cartTotal: 0
      }
    };
  },
  components: {},
  created() {
    UserInfoApi().then(res => {
      if (res.data.code === 0) {
        let { userInfo } = res.data.data;
        this.userInfo = userInfo;
      }
    });
  }
};
</script>
 
<style lang = "less" scoped>
@import "../assets/base";
main {
  border-top: 2px solid #ececec;
  padding-bottom: 50px;
  min-height: 740px;
  aside {
    width: 200px;
    background: #e7e7e7;
    margin-right: 60px;
    .avatar {
      width: 100px;
      height: 100px;
      display: block;
      margin: 30px auto 19px;
    }
    .userInfo {
      text-align: center;
      margin-bottom: 43px;
      a {
        text-decoration: none;
        color: @blue;
      }
    }
    .title {
      display: flex;
      align-items: center;
      padding-left: 18px;
      margin-bottom: 17px;
      img {
        margin-right: 6px;
      }
    }
    ul {
      padding-left: 20px;
      li {
        margin-bottom: 18px;
        color: #666666;
        cursor: pointer;
        &.active {
          border-left: 2px solid @blue;
          padding-left: 10px;
          color: @blue;
        }
      }
    }
  }
  article {
    flex: 1;
  }
}
</style>